package com.ymatou.iapi.productprice.testcase.old20210121;

import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productprice.parameter.GetSpuMinPriceBean;
import com.ymatou.iapi.productprice.service.GetSpuMinPriceCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.util.List;
import java.util.stream.Collectors;
/**
*获取SPU最小规格价Test
*FreeMaker Template自动生成代码
*/
@TestSuite
@Ignore //	全球业务下架
public class Ts_GetSpuMinPrice{
	private static GetSpuMinPriceBean getspuminpriceBean;
	private static GetSpuMinPriceCall getspuminpriceCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取SPU最小规格价Test");
	}

	@Before
	public void caseUp() {
		getspuminpriceBean=new GetSpuMinPriceBean();
		getspuminpriceCall=new GetSpuMinPriceCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getspuminpriceCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetSpuMinPrice_001() {
		Logger.start(true,"正确数据，成功");
		try {
			AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerGlobalPspProductRequest(3383);
			String productId = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();
			Thread.sleep(3000);
			List<String> catalogIds = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(x->x.getsCatalogId()).collect(Collectors.toList());
			System.out.println(catalogIds);
			
			getspuminpriceBean.setBuyerId(3383);
			getspuminpriceBean.setCatalogIdList(catalogIds);
			getspuminpriceCall.setData(getspuminpriceBean);
			getspuminpriceCall.callService();			
			Logger.verifyEquals("200", getspuminpriceCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}